package com.lilili.ssh.relation.model;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import com.lilili.ssh.base.BaseModel;
import com.lilili.ssh.book.model.Book;
import com.lilili.ssh.user.model.User;

@Entity
@Table(name = "relation", uniqueConstraints = {})
public class Relation extends BaseModel {

	private static final long serialVersionUID = 1L;
	private Book book;
	private User user;
	private String username;
	private String bookname;

	@ManyToOne(cascade = {}, fetch = FetchType.LAZY)
	@JoinColumn(name = "BOOKID",  nullable = false, insertable = true, updatable = true)
	public Book getBook() {
		return this.book;
	}

	public void setBook(Book book) {
		this.book = book;
	}

	@ManyToOne(cascade = {}, fetch = FetchType.LAZY)
	@JoinColumn(name = "USERID",  nullable = false, insertable = true, updatable = true)
	public User getUser() {
		return this.user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	@Column(name = "USERNAME",  nullable = true, length = 32)
	public String getUsername() {
		return this.username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	@Column(name = "BOOKNAME",  nullable = true, length = 100)
	public String getBookname() {
		return this.bookname;
	}

	public void setBookname(String bookname) {
		this.bookname = bookname;
	}

}